#include "kernel/types.h"
#include "kernel/stat.h"
#include "user/user.h"

int main(){
	int pid;
	int parent[2];
	int init[2];
	pipe(parent);
	pipe(init);
	if((pid =fork()) == 0){
		char b[2];
	       close(init[1]);
	       read(init[0], b, 1);
	       close(init[0]);
	       fprintf(1, "%d: received ping\n", getpid());

	       close(parent[0]);
	       write(parent[1], b, 1);
	       close(parent[1]);
	       exit(0);
	}
	char a[2];
	close(init[0]);
	write(init[1], "a", 1);
	close(init[1]);	

	close(parent[1]);
	read(parent[0], a, 1);
	close(parent[0]);
	fprintf(1, "%d: received pong\n", getpid());

	exit(0);
}

